/*
 * @Author: 来朝奇
 * @Date: 2020-01-19 08:41:41
 * @LastEditTime : 2020-05-26 21:58:28
 * @LastEditors  : Please set LastEditors
 * @Description: 定义全局公用vue实例方法
 */
const install = (Vue) => {
  Vue.prototype.deepCopy = obj => {
    return obj && JSON.parse(JSON.stringify(obj))
  }

  Vue.prototype.dateFormat = (obj, format) => {
    if (obj instanceof Date) {
      // eslint-disable-next-line no-undef
      return kendo.toString(kendo.parseDate(obj, format), format)
    }
    return obj
  }

  Vue.prototype.dateAddDays = (data, days) => {
    return new Date((data / 1000 + (86400 * days)) * 1000)
  }

  Vue.prototype.uid = () => {
    return (S4() + S4() + S4() + S4() + S4() + S4() + S4() + S4())
  }
  Vue.prototype.timestamp = () => {
    return Date.parse(new Date())
  }
}
function S4() {
  return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1)
}

export default install
